#include "Arduino.h"
#include "sonicRange.h"

sonicRange::sonicRange(void) {
  _buf = 0;
}


boolean sonicRange::parse(byte theChar) {
  boolean done = false;
  switch(theChar) {
    case 'R': {
      _buf = 0;
    break;
    }
    case 0x0D: {
      range = int((254L * _buf) / 100L);
      _buf = 0;
      done = true;
    break;
    }
    default: {
      _buf = (_buf * 10) + long(theChar - 48);
    }
  }
  return done;
}
